Skip to content

Store agent-made facts with their source text - #714

Merged
arrry-hydraDB merged 1 commit into
hydra-db:mainfrom
jaywyawhare:feat/no-key-agent-path
Dec 5, 2026
Merged

arrry-hydraDB merged 1 commit into
hydra-db:mainfrom
jaywyawhare:feat/no-key-agent-path

Conversation

@jaywyawhare

@jaywyawhare jaywyawhare commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An agent with no LLM key can extract the facts itself and pass them to insert.text with the text, so passages, citations, and replace_source survive.
Relation evidence that names no source_id takes the call's, and the skill and tool descriptions point agents without a key at this path.

Implementation details

Door: one-way

Cleanup: none

Decisions

  • insert.text takes facts. With them nothing is extracted, and the text goes through the same source recording as extraction, so passages, chunk citations, and replace_source behave as they do for extracted text. I put this on insert.text rather than adding text to insert.facts because insert.text already owns the provenance options (metadata, chunking, replace_source).
  • Caller facts keep insert.facts semantics: in strict schema mode a fact outside the schema is rejected, not dropped as extracted facts are. result.tiers has no extraction entry.
  • Relation evidence with no source_id key inherits the call's, in insert.text and insert.facts. An explicit source_id, including null, is kept as given.
  • facts together with instructions or prompts raises invalid_argument on the facts field, since those only guide extraction.
  • TypeScript adds FactsInput, which is Extraction with an optional evidence source_id, for insert.text's facts and for insert.facts, so callers can omit it without a cast. Python already takes a mapping.
  • The CLI gets insert text --facts FILE and the MCP insert_text tool gets facts, in both SDKs. The skill gets a "Without an LLM key" section, and the insert_text and insert_facts tool descriptions tell an agent with no LLM to extract and pass the facts.

Validation

  • New tests/test_insert_with_facts.py and typescript/test/insertWithFacts.test.ts (7 tests each) fail on main and pass here. They cover the stored source and its cited passage, source_id inheritance next to an explicit one, replace_source retiring what only the older version stated, strict mode, the instructions/prompts guard, and the CLI and MCP paths. No existing test inserts caller facts with their text.
  • A new conformance case, insert_with_facts, checks that both SDKs return the same ids, tiers, evidence, retrieval context, and guard error. The MCP test that pins the insert_text arguments now includes facts.
  • scripts/precheck.py --base origin/main passes. Ruff, Biome, and tsc --noEmit are clean. Targeted suites pass on Kuzu. The only local failures are the code-parsing conformance cases, which need the code extra that is not installed here, and the pipe test that spawns an installed CLI; both fail on main the same way.
  • No new error codes, so docs/errors.md is unchanged.

Limits

Caller evidence keeps its quote and is tied to the new source version, but its chunk_id is not derived from the quote. Retrieval still cites the source at the chunk level. No model is bundled and nothing calls an LLM by default, as the issue scopes.

Linked issue

Closes #674

AI Assistance

AI tools helped write and test parts of this. I reviewed and ran every change.

Checklist

  • Implements an issue a maintainer has /approved.
  • Small and scoped to that issue.
  • New errors have a code and hint, the same on API, CLI, and MCP in both SDKs (see AGENTS.md). No new codes; the guard uses invalid_argument with field="facts" and the same text in both SDKs.
  • Breaking changes described below, or none.

Breaking changes

None.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@arrry-hydraDB arrry-hydraDB added feature New capability area: extraction LLM extractor and clients area: cli-mcp CLI and MCP server effort: L Design change or many modules labels Dec 5, 2026
@jaywyawhare
jaywyawhare force-pushed the feat/no-key-agent-path branch from e33254c to aff22d5 Compare December 5, 2026 01:50

@arrry-hydraDB arrry-hydraDB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arrry-hydraDB
arrry-hydraDB merged commit f607449 into hydra-db:main Dec 5, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli-mcp CLI and MCP server area: extraction LLM extractor and clients effort: L Design change or many modules feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Design the no-key path as the default for agent users

2 participants